class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age


p = Person('Black', 20)
print(p.name, p.age)


class Example:
    class_attribute = "共享的类属性"

    def __init__(self, value):
        self.instance_attribute = value


e1 = Example("实例1")
e2 = Example("实例2")
print(e1.class_attribute)
print(e1.instance_attribute)
print(e2.instance_attribute)


class Dog:
    def __init__(self, name):
        self.name = name

    def bark(self):
        return f"{self.name} is barking!"


d = Dog("buddy")
print(d.bark())


class Math:
    @classmethod
    def add(cls, a, b):
        return a + b


print(Math.add(5, 7))


class Utils:
    @staticmethod
    def is_even(number):
        return number % 2 == 0


print(Utils.is_even(2))


class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __str__(self):
        return f"Point({self.x}, {self.y})"


p = Point(3, 4)
print(p)